let _id = window.location.href.split("=")[1]
axios.get('https://cnodejs.org/api/v1/topic/'+_id)
.then(res => {
    let data = res.data.data; 
    // 内容渲染
    function render(){
        let title1 = document.querySelector('._title_1')
        let title2 = document.querySelector('._title_2')
        let content1 = document.querySelector('.content_1')
        let content2 = document.querySelector('.content_2')       
        let title6 = document.querySelector('._title_6')
        let content5 = document.querySelector('.content_5')       

        if(_id == data.id){
            let str ='';            
            str=`<ul>
            <li>发布时间:
            ${data.last_reply_at.slice(0,10)}
            </li>
            <li>作者:
            ${data.author.loginname}
            </li>
            <li>浏览次数:
            ${data.visit_count}
            </li>
            <li>来自:
            ${data.tab == 'share'? '分享':'问答'}
            </li></ul>`
            let tit =`${ data.top == true ? '<span class="put_top">置顶</span>&nbsp; ' : ''}`
            title1.innerHTML = tit + data.title
            title2.innerHTML = str
            content1.innerHTML = data.content
            content2.innerHTML = `
            <img src="${data.author.avatar_url}" style="width: 100px ;height: 100px;">
            &nbsp;&nbsp;<span>${data.author.loginname}</span>
            <br><br><p>积分：未知</p>
            <p>"该用户未填写个性签名。"</p>
            `
            // 评论
            title6.innerHTML = `
            <div>${data.replies.length}回复</div>
            `
            let str1 = '';
            for(let i = 0; i<data.replies.length; i++){
                // console.log(data.replies[i].author.avatar_url);
                str1+=`<div class="comment">
                <img src="${data.replies[i].author.avatar_url}" style="width: 50px ;height: 50px;">
                ${data.replies[i].author.loginname}&nbsp ${i+1}楼<br>
                ${data.replies[i].content}
                </div><hr/>`
            }
            content5.innerHTML = str1
        }   
        // console.log(data);
    }
    render()




}).catch( err => console.log('axios 错误=>', err));



